package com.kfm.spring.service.impl;

import com.kfm.spring.domain.SysUser;
import com.kfm.spring.mapper.SysUserMapper;
import com.kfm.spring.service.SysUserService;
import com.kfm.spring.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserMapper userMapper;

    @Override
    public SysUser login(SysUser sysUser) {
        if (ObjectUtils.isEmpty(sysUser)){

        }
        sysUser.setPassword(MD5Util.encode(sysUser.getPassword()));
        List<SysUser> sysUsers = userMapper.selectAll(sysUser);
        return sysUsers.size() > 0 ? sysUsers.get(0) : null;
    }
}
